package cn.edu.nit.sys.mapper;

import cn.edu.nit.sys.dto.StudentDTO;
import cn.edu.nit.sys.entity.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface StudentMapper extends BaseMapper<Student> {

    Page<StudentDTO> getStudentList(Page<StudentDTO> page, String siftName, String deptId, String majorId);

    @Select("select *, department as dept, ifnull(sex, '未填写') as sex from sys_student where id = #{id}")
    Student getStudentById(String id);

    @Select("select id from sys_student order by id desc limit 1")
    String getLastStudentId();

    @Select("select dept_id from sys_department where name = #{dept} limit 1")
    String getDeptId(String dept);

    @Select("select major_id from sys_department where major = #{major}")
    String getMajorId(String major);


}
